// 打开或创建数据库
let request = indexedDB.open("myDatabase", 1);

request.onerror = event => {
    console.log("数据库打开失败", event.target.errorCode);
};

request.onsuccess = event => {
    console.log("数据库打开成功");
    db = event.target.result; // 获取数据库实例
    debugger
};

// 数据库更新
request.onupgradeneeded = event => {
    var db = event.target.result;
    // 创建一个对象存储空间
    var objectStore = db.createObjectStore("myObjectStore", {keyPath: "id"});
};